package com.holyant.goods.enums;

/**
 * 规格数量枚举
 */
public enum SpecsQtyEnum {

    ONE(10, "1"),
    TWO(20, "2"),
    THREE(30, "3"),
    FOUR(40, "4"),
    FIVE(50, "5"),
    SIX(60, "6");

    private final Integer code;
    private final String name;

    SpecsQtyEnum(Integer code, String name)
    {
        this.code = code;
        this.name = name;
    }

    public Integer getCode()
    {
        return code;
    }

    public String getName()
    {
        return name;
    }

    public static String getNameByCode(Integer code) {
        for (SpecsQtyEnum item : SpecsQtyEnum.values()) {
            if (item.getCode().equals(code)) {
                return item.getName();
            }
        }
        return null;
    }

    public static Integer getCodeByName(String name) {
        for (SpecsQtyEnum item : SpecsQtyEnum.values()) {
            if (item.getName().equals(name)) {
                return item.code;
            }
        }
        return null;
    }

    public static SpecsQtyEnum parse(Integer code) {
        for (SpecsQtyEnum item : SpecsQtyEnum.values()) {
            if (item.getCode().equals(code)) {
                return item;
            }
        }
        return null;
    }

    public static SpecsQtyEnum parseByName(String name) {
        for (SpecsQtyEnum item : SpecsQtyEnum.values()) {
            if (item.getName().equals(name)) {
                return item;
            }
        }
        return null;
    }
}
